
<cfif UCASE(CLIENT.DBMS) EQ "MSSQL">
	<cfset company_dsn = '#client.company_dsn#.dbo'>
<cfelse>
	<cfset company_dsn = '#client.company_dsn#'>
</cfif> 

<CFQUERY NAME="QueryView" DATASOURCE="#client.global_dsn#">
	SELECT A.LASTNAME, A.FIRSTNAME, A.MIDDLENAME, B.USERID,A.PERSONNELIDNO
	FROM #company_dsn#.CMFPA A, EGRGUSERMASTER B
	WHERE
		(A.GUID = B.GUID)
	<CFIF IsDefined("Form.edtValFilter") AND #Form.edtValFilter# NEQ "">
		AND #Form.cmbSort# LIKE '%#Form.edtValFilter#%'
	</CFIF>
	<CFIF IsDefined("form.cmbSort") AND NOT ISDEFINED("FORM.REFRESH")>
		ORDER BY #form.cmbSort# <CFIF IsDefined("form.ascdesc")>#form.ascdesc#</CFIF>
	<CFELSE>
		ORDER BY B.USERID,A.LASTNAME,A.FIRSTNAME
	</CFIF>
</CFQUERY>
<CFSET lstAddtnlButton="btnAction~Add Employee~Add,btnpowerfilter~Filter~Filter,btnBackAdd~Back~Back">
<CFSET lstOrder="Personnel Id No~PERSONNELIDNO~ftString,Last Name~LASTNAME~ftString,First Name~FIRSTNAME~ftString">
<CFSET frmname="frmAddEmps">
<CFMODULE TEMPLATE="#client.common_path#cfm_wswindow.cfm" TITLE="Select Employees">
<CFOUTPUT>
	<CFSET act = URLEncodedFormat(encrypt("addemployees",client.ek))>
	
	<FORM ACTION="index.cfm?powermast=" METHOD="POST" NAME="frmAddEmps">
	<CFINCLUDE template="#client.common_path#/toolbar.cfm">
	<CFIF isDefined("form.refresh")>
		<CFSET checkList = "">
		<CFSET nStartrow = 1>
	</CFIF>
</CFOUTPUT>
<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=2 WIDTH="100%">
	<CFOUTPUT>
		<TR BGCOLOR="#client.color_tblhead#">
			<TD HEIGHT=18></TD>
			<TD CLASS="boldwhite">User ID</TD>
			<TD CLASS="boldwhite">Personnel ID No.</TD>
			<TD CLASS="boldwhite">Last Name</TD>
			<TD CLASS="boldwhite">First Name</TD>
			<TD CLASS="boldwhite">Middle Name</TD>
		</TR>
	</CFOUTPUT>
	<CFIF QueryView.recordcount GT 0>
		<CFOUTPUT QUERY="QueryView" STARTROW="#nStartrow#" MAXROWS="#Evaluate(nEndrow - nStartrow + 1)#">
			<CFQUERY NAME="IsExists" DATASOURCE="#client.COMPANY_dsn#">
				SELECT PERSONNELIDNO
				FROM CINWSPOWERUSER
				WHERE
					(PERSONNELIDNO   = '#PERSONNELIDNO#')
			</CFQUERY>
			<TR BGCOLOR="#IIf(CurrentRow Mod 2, "client.color_tblset2", "client.color_tblset1")#" VALIGN="top">
				<TD>
					<INPUT TYPE="checkbox" NAME="chkPERSONNELIDNO" VALUE="#PERSONNELIDNO#~#USERID#" <CFIF IsExists.recordcount>CHECKED</CFIF>>
				</TD>
				<TD>#USERID#</TD>
				<TD>#PERSONNELIDNO#</TD>
				<TD>#LASTNAME#</TD>
				<TD>#FIRSTNAME#</TD>
				<TD>#MIDDLENAME#</TD>
			</TR>
		</CFOUTPUT>
	<CFELSE>
		<tr><td class="bold" WIDTH=250>No records found in the current filter.</td></tr>
	</CFIF>
	<CFOUTPUT>
		<TR BGCOLOR="#client.color_tblfoot#">
			<TD COLSPAN=8	CLASS="boldwhite" HEIGHT=18>Records: #nStartrow# - #nEndRow# of #QueryView.RecordCount#</TD>
		</TR>
	</CFOUTPUT>
</TABLE>
</FORM>
<CFMODULE TEMPLATE="#client.common_path#cfm_wswindow.cfm" TOP="False">
